package org.bibpessoal.util;
import java.sql.Connection;
import com.mchange.v2.c3p0.ComboPooledDataSource;

public class PoolConexao{
	
	private static ComboPooledDataSource pool = null;
	
	public static Connection getConexao() throws Exception{ 
		
		inicializa();
		return pool.getConnection();
		
	}
	
	public static void inicializa() throws Exception{
		if(pool == null){
			pool = new ComboPooledDataSource();
			pool.setDriverClass("com.mysql.jdbc.Driver"); //loads the jdbc driver            
			pool.setJdbcUrl( "jdbc:mysql://localhost/bibliotecaPessoal8" );
			pool.setUser("root");                                  
			pool.setPassword("ninocafe");
			pool.setMaxStatements(10);
		}
	}
}
